﻿//反馈建议


var userReply = function (elCell, oRecord, oColumn, sData) {
    var ID = oRecord.getData("ID");
    var UserID = oRecord.getData("AddUser")
    var isReply = oRecord.getData("isReply")
    //parent.addTabs(pagetitle, encodeURI("../EHR/MsgReplyPage.aspx?r=" + Math.random() + "&id=" + ID +"&UserID="+UserID+""));
    elCell.innerHTML = "<a href='javascript:transForForm(\"点击回复\",\"../EHR/MsgReplyPage.aspx?r=" + Math.random() + "&id=" + ID + "&UserID=" + UserID + "\");'>点击回复</a>";

    if (isReply > 0) {
        elCell.innerHTML += "<span style='color:green;'>(已回复)</span>";
    }
    //    var WorkFlowInstanceId = oRecord.getData("WorkFlowInstanceId");
    //    var workflowId = oRecord.getData("WorkFlowId");
    //    var taskCaption = oRecord.getData("TaskCaption");
    //    var url = '"' + "../../Crm/BasePages/WorkflowMap.aspx?WorkFlowInstanceId=" + WorkFlowInstanceId + "&workflowId=" + workflowId + '"';
    //    var title = '"' + taskCaption + '流程图"';
    //    elCell.innerHTML = "<a href='javascript:transForForm(" + title + "," + url + ")'>流程图</a><br />";
}

var GetTitle = function (elCell, oRecord, oColumn, sData) {
    var ID = oRecord.getData("ID");
    var title = oRecord.getData("title");
    elCell.innerHTML = "<a href='javascript:transForForm(\"" + title + "\",\"/Extend/MsgreplyModify.aspx?r=" + Math.random() + "&entity=V_MsgFKList&id=" + ID + "&PageState=View\");'>" + title + "</a><br />";

}


var transForForm = function (title, url) {
    parent.addTabs(title, url);
}
    parent.NeedRefreshPage = this;

function reply_Function() {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    //var a = record.getData(const_entityID)
    
    if (record == null) {
        alert("请选择一条记录");
        return;
    }

    var UserID = record.getData("AddUser");
    var ID = record.getData("ID");

    //显示弹出窗口
//    document.getElementById("EditUIWindow").src = "../EHR/MsgReplyPage.aspx?ID=" + ID + "&UserID=" + UserID;
//    document.getElementById("yui-gen7-button").style.display = "none";
//    YAHOO.example.container.dialog1.setHeader("回复信息");
//    YAHOO.example.container.dialog1.show();

    //显示新选项卡
    var pagetitle = "回复信息";
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../EHR/MsgReplyPage.aspx?r=" + Math.random() + "&id=" + ID +"&UserID="+UserID+""));
    parent.NeedRefreshPage = this;

}

//获取url里的参数值 name:参数名称
function getPar(source, name) {
    var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
    if (reg.test(source))
        return RegExp.$2;
    return "";
};

//双击事件
function CustomDbClick() {
    if (typeof (fnCustomEdit) == "function") {
        reply_Function();
    }
}
//----------------------------------------------

//增加
var fnCustomAdd = function () {
    //    var empName = getPar(decodeURI(location.href), "empName");
    //    var empId = getPar(decodeURI(location.href), "empId");
    //    var deptName = getPar(decodeURI(location.href), "deptName");
    //    var postName = getPar(decodeURI(location.href), "postName");
    //    document.getElementById("dialog1_h").innerHTML = "新增兼职岗位——" + empName;
    //    document.getElementById("EditUIWindow").src = "../EHR/hrAddPartTimePost.aspx?empId=" + empId + "&deptName=" + deptName + "&postName=" + postName;
    //    SetDWH(500, 300, YAHOO.example.container.dialog1);
    //    YAHOO.example.container.dialog1.show();
    var pagetitle = "提交建议";
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/MsgreplyModify.aspx?r=" + Math.random() + "&entity=V_MsgFKList&id="));
    parent.NeedRefreshPage = this;
}
//编辑
var fnCustomEdit = function () {
    //    var recordID = myDataTable.getSelectedRows()[0];
    //    record = myDataTable.getRecord(recordID);
    //    if (record == null) {
    //        alert("请选择一条记录");
    //        return;
    //    }
    //    var const_EditEntity = "tmInformation";
    //    var pagetitle = "培训资料修改";
    //    parent._employeeTitle = pagetitle;
    //    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID) + ""));
    //    parent.NeedRefreshPage = this;
}
//删除
var fnCustomDelete = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }


    var const_EditEntity = "DatSysNewsMonth";

    var list = mDataTable.getRecordSet()._records;
    var elist = [];
    dl = [];
    for (var i = 0; i < list.length; i++) {
        if (list[i]._oData["iSun_Selected"] == true) {
            elist.push(list[i]._oData[const_entityID]);
            dl.push(list[i]._sId); //获取行ID；
        }
    }

    //    if (elist.length == 0) {
    //        var recordID = myDataTable.getSelectedRows()[0];
    //        record = myDataTable.getRecord(recordID);
    //        SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&entity=hrEmployeePositions&id=" + record.getData(const_entityID);
    //    }
    //    else {
    //        SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&entity=hrEmployeePositions&json=" + elist.join(",");
    //    }
    SaveUrl = "../Extend/AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
    YAHOO.example.container.dialog3.show();
}

//初始化内置页面时
window.onload = function () {
    document.getElementById("btnAddNew-button").innerHTML = "提交建议";
    //window.parent.$("#tabs").tabs('close', '提交月度建议');
}
//反馈建议
var fncontent = function (elCell, oRecord, oColumn, sData) {
    elCell.innerHTML = oRecord.getData("content").substring(0, 30);
}
